package com.fzn.mvc.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @program: SpringMVC-demo1
 * 描述：//@ControllerAdvice将当前类标识为异常处理的组件
 * @author: fzn
 * @create: 2022-03-03 10:58
 **/

@ControllerAdvice
public class ExceptionController {

    @ExceptionHandler(ArithmeticException.class)
    public String handleArithmeticException(Exception ex, Model model){
        model.addAttribute("ex", ex);
        return "error";
    }

}